/**
 * @description:  获取search配置信息
 * @param {*} type  1 在供气瓶  2 返库气瓶  3 过期气瓶
 * @return {Array<CommonSearch.SearchOption>}
 */
export const useSearchOption = (type: 1 | 2 | 3): Array<CommonSearch.SearchOption> => {
  const cylinderNo: CommonSearch.SearchOption = {
    label: "气瓶号",
    key: "cylinderNo",
    value: "",
    type: "input",
    placeholder: "请输入气瓶号"
  };

  const gasName: CommonSearch.SearchOption = {
    label: "气体名称",
    key: "gasName",
    value: "",
    type: "input",
    placeholder: "请输入气体名称"
  };

  const materialNo: CommonSearch.SearchOption = {
    label: "料号",
    key: "materialNo",
    value: "",
    type: "input",
    placeholder: "请输入料号"
  };

  const storesRequisitionNo: CommonSearch.SearchOption = {
    label: "领料单号",
    key: "storesRequisitionNo",
    value: "",
    type: "input",
    placeholder: "请输入领料单号"
  };

  const deviceCode: CommonSearch.SearchOption = {
    label: "设备编号",
    key: "deviceCode",
    value: "",
    type: "input",
    placeholder: "请输入设备编号"
  };

  const materialHandler: CommonSearch.SearchOption = {
    label: "领料人",
    key: "materialHandler",
    value: "",
    type: "input",
    placeholder: "请输入领料人"
  };

  const receiver: CommonSearch.SearchOption = {
    label: "接收人",
    key: "receiver",
    value: "",
    type: "input",
    placeholder: "请输入接收人"
  };

  const operator: CommonSearch.SearchOption = {
    label: "更换人",
    key: "operator",
    value: "",
    type: "input",
    placeholder: "请输入更换人"
  };

  const status: CommonSearch.SearchOption = {
    label: "气体状态",
    key: "status",
    value: "",
    type: "select",
    option: [
      {
        label: "合格",
        value: 1
      },
      {
        label: "即将过期",
        value: 2
      },
      {
        label: "过期",
        value: 3
      }
    ],
    placeholder: "请选择气体状态"
  };

  const inertGas: CommonSearch.SearchOption = {
    label: "是否惰性",
    key: "inertGas",
    value: "",
    type: "select",
    option: [
      {
        label: "是",
        value: "是"
      },
      {
        label: "否",
        value: "否"
      }
    ],
    placeholder: "请选择是否惰性"
  };

  const expirationDateStart: CommonSearch.SearchOption = {
    label: "有效期",
    key: "expirationDateStart",
    realKeys: ["expirationDateStart", "expirationDateEnd"],
    value: [],
    type: "daterange",
    span: type === 1 ? 8 : 6
  };

  const delayDateStart: CommonSearch.SearchOption = {
    label: "延期至",
    key: "delayDateStart",
    realKeys: ["delayDateStart", "delayDateEnd"],
    value: [],
    type: "daterange",
    span: type === 1 ? 8 : 6
  };

  const onlineDateStart: CommonSearch.SearchOption = {
    label: "换瓶日期",
    key: "onlineDateStart",
    realKeys: ["onlineDateStart", "onlineDateEnd"],
    value: [],
    type: "daterange",
    span: 8
  };

  const onlineDateStart2: CommonSearch.SearchOption = {
    label: "上线日期",
    key: "onlineDateStart",
    realKeys: ["onlineDateStart", "onlineDateEnd"],
    value: [],
    type: "daterange",
    span: type === 1 ? 8 : 6
  };

  const offlineDateStart: CommonSearch.SearchOption = {
    label: "下线日期",
    key: "offlineDateStart",
    realKeys: ["offlineDateStart", "offlineDateEnd"],
    value: [],
    type: "daterange",
    span: type === 1 ? 8 : 6
  };

  const returnWarehouse: CommonSearch.SearchOption = {
    label: "是否返回",
    key: "returnWarehouse",
    value: "",
    type: "select",
    option: [
      {
        label: "是",
        value: "是"
      },
      {
        label: "否",
        value: "否"
      }
    ],
    placeholder: "请选择是否返回"
  };

  switch (type) {
    case 1:
      return [
        cylinderNo,
        gasName,
        materialNo,
        storesRequisitionNo,
        deviceCode,
        materialHandler,
        receiver,
        operator,
        status,
        inertGas,
        expirationDateStart,
        delayDateStart,
        onlineDateStart
      ];
    case 2:
      return [
        cylinderNo,
        gasName,
        materialNo,
        storesRequisitionNo,
        deviceCode,
        materialHandler,
        receiver,
        operator,
        inertGas,
        expirationDateStart,
        delayDateStart,
        onlineDateStart2,
        offlineDateStart,
        returnWarehouse
      ];
    case 3:
      return [
        cylinderNo,
        gasName,
        materialNo,
        storesRequisitionNo,
        deviceCode,
        materialHandler,
        receiver,
        operator,
        inertGas,
        expirationDateStart,
        delayDateStart,
        onlineDateStart2,
        offlineDateStart
      ];
  }
};

/**
 * @description:  获取table表格的表头（cloumns）信息
 * @param {*} type  1 在供气瓶  2 返库气瓶  3 过期气瓶
 * @return {Array<CommonTable.TableCloumnsType>}
 */
export const useTableCloumns = (type: 1 | 2 | 3): Array<CommonTable.TableCloumnsType> => {
  const tagMapOption = new Map([
    [
      "合格",
      {
        value: 1,
        label: "合格",
        rgb: "16, 185, 129"
        // color: "#10B981",
        // backgroundColor: "#E8F8F3"
      }
    ],
    [
      "即将过期",
      {
        value: 2,
        label: "即将过期",
        rgb: "245, 158, 0"
        // color: "#FFB90F",
        // backgroundColor: "#FFF8DC"
      }
    ],
    [
      "过期",
      {
        value: 3,
        label: "过期",
        rgb: "239, 68, 68"
        // color: "#EF4444",
        // backgroundColor: "#FEECEC"
      }
    ]
  ]);
  const o_1 = { label: "气瓶号", prop: "cylinderNo", sortable: true, width: 150 };
  const o_2 = { label: "气体名称", prop: "gasName", width: 150 };
  const o_3 = {
    label: "气瓶状态",
    prop: "statusName",
    width: 100,
    tagMapOption,
    defaultTagValue: "合格",
    mapRow: ({ row: { statusName = "" } }: any) => ({ value: statusName, label: statusName })
  };
  const o_3_1 = { label: "满瓶量", prop: "maximalCapacity", width: 100 };
  const o_4 = { label: "有效期", prop: "expirationDate", sortable: true, width: 110 };
  const o_5 = { label: "延期至", prop: "delayDate", sortable: true, width: 110 };
  const o_6 = { label: "剩余天数", prop: "remainingDays", sortable: true, width: 110 };
  const o_7 = { label: "料号", prop: "materialNo", width: 150 };
  const o_7_1 = { label: "更换工单号", prop: "workOrderNo", width: 150 };
  const o_8 = { label: "是否惰性", prop: "inertGas", width: 90 };
  const o_9 = { label: "申请日期", prop: "applicationDate", sortable: true, width: 110 };
  const o_10 = { label: "成本中心", prop: "costCenter", width: 100 };
  const o_11 = { label: "领料单号", prop: "storesRequisitionNo", width: 140 };
  const o_12 = { label: "领料人", prop: "materialHandler", width: 90 };
  const o_121 = { label: "上线日期", prop: "onlineDate", sortable: true, width: 110 };
  const o_13 = { label: "接收人", prop: "receiver", width: 90 };
  const o_14 = { label: "换瓶日期", prop: "onlineDate", sortable: true, width: 110 };
  const o_15 = { label: "更换人", prop: "onlineOperator", width: 90 };
  const o_16 = { label: "	设备编号", prop: "deviceCode", width: 140 };
  const o_17 = { label: "点位", prop: "position", width: 80 };
  const o_171 = { label: "上线操作人", prop: "onlineOperator", width: 90 };
  const o_172 = { label: "下线日期", prop: "offlineDate", sortable: true, width: 110 };
  const o_173 = { label: "下线操作人", prop: "offlineOperator", width: 90 };
  const o_174 = { label: "是否返回", prop: "returnWarehouse", width: 100 };
  const o_175 = { label: "满瓶量", prop: "maximalCapacity", width: 70 };
  const o_176 = { label: "剩余量", prop: "surplusCapacity", width: 100 };
  const o_177 = { label: "剩余比例", prop: "surplusRate", width: 100 };
  const o_18 = { label: "备注", prop: "remark", width: 200 };

  switch (type) {
    case 1:
      // return [o_1, o_2, o_3, o_3_1, o_4, o_5, o_6, o_7, o_7_1, o_8, o_9, o_10, o_11, o_12, o_13, o_14, o_15, o_16, o_17, o_18];
      return [o_1, o_2, o_3, o_4, o_5, o_6, o_8, o_3_1, o_7, o_9, o_10, o_11, o_12, o_13, o_14, o_16, o_17, o_15, o_18];
    case 2:
      return [o_1, o_2, o_3, o_3_1, o_4, o_5, o_6, o_7, o_7_1, o_8, o_9, o_11, o_12, o_121, o_16, o_17, o_171, o_172, o_173, o_174, o_18];
    case 3:
      return [
        o_1,
        o_2,
        o_3,
        o_4,
        o_5,
        o_6,
        o_7,
        o_7_1,
        o_8,
        o_9,
        o_11,
        o_12,
        o_13,
        o_121,
        o_16,
        o_17,
        o_171,
        o_172,
        o_173,
        o_175,
        o_176,
        o_177,
        o_18
      ];
  }
};
